package com.sunnada.exam.controller;

import com.sunnada.exam.dto.AnswerDto;
import com.sunnada.exam.service.QuestionService;
import com.sunnada.exam.vo.QuestionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;
import java.util.Map;

@Controller
public class QuestionController {

    @Autowired
    QuestionService questionService;

    @GetMapping("/")
    public String examPage(Map<String, Object> model) {
        List<QuestionVo> qs = questionService.list("1");
        model.put("questions",qs);
        return "exam";
    }

    @PostMapping("examSubmit")
    public String examSubmit(AnswerDto ans){
        return "pdp/"+questionService.check(ans).getPage();
    }

}
